package com.dst.service.impl;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dst.entity.AuctionRecord;
import com.dst.dao.AuctionRecordMapper;
import com.dst.service.IAuctionRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 董胜涛
 * @since 2022-04-27
 */
@Service
public class AuctionRecordServiceImpl extends ServiceImpl<AuctionRecordMapper, AuctionRecord> implements IAuctionRecordService {

  @Override
  public void chekPrice(AuctionRecord auctionRecord) {
    Integer auctionId = auctionRecord.getAuctionId();
    Double aDouble = baseMapper.chekPrice(auctionId);
    Double recordPrice = auctionRecord.getRecordPrice();
    if(recordPrice>aDouble){
      this.save(auctionRecord);
    }else {
      throw new RuntimeException("出价信息低于最高价格");
    }
  }
}
